package gui;

import javax.swing.JLabel;
import javax.swing.JList;
import javax.swing.ListModel;
import javax.swing.event.ListDataListener;
import javax.swing.event.ListSelectionEvent;
import javax.swing.event.ListSelectionListener;

/**
 * @author Jonathan Maret
 * JList used to contain classes for the logged user
 *
 */
public class ListClass extends JList<JLabel>{
	
	String[] data;
	public String[] getData() {
		return data;
	}
	public void setData(String[] data) {
		this.data = data;
		this.setModel(new ListClassModel(data));
	}
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	public ListClass(String[] data) {
		super(new ListClassModel(data));
		this.data = data;

	}
	private static class ListClassModel implements ListModel{
		String[] data;

		public ListClassModel(String[] data) {
			super();
			this.data = data;
		}


		@Override
		public void addListDataListener(ListDataListener l) {
			
		}

		@Override
		public Object getElementAt(int index) {
			return data[index];
		}

		@Override
		public int getSize() {
			return data.length;
		}

		@Override
		public void removeListDataListener(ListDataListener l) {
			// TODO Auto-generated method stub

		}
		
	}
	

}
